<template>
	<view>
		<view class="order-top">
			<view class="top-content">
				<view class="oil-item-top">
					<image :src="detail.image" mode="aspectFill">
					</image>
					<view class="oil-item-data">
						<view class="oil-title">
							<text>{{detail.name}}</text>
							<view class="collect" @click="collect(detail)">
								<text class="iconfont icon-shoucang" v-if="detail.is_collect == 0"></text>
								<text class="iconfont icon-shoucang1" v-if="detail.is_collect == 1"></text>
							</view>
						</view>
						<view class="address-box">
							<text class="address">{{detail.address}}</text>
							<view class="distance-box">
								<!-- <text class="address-icon iconfont icon-shouhuodizhi"></text> -->
								<text class="distance" @click="toMap(detail)">距离{{detail.distance}}</text>
								<img class='GPS-img' src="../../static/images/dizhi.png" alt="" @click="toMap(detail)">
								<view class="kp" @click="kpPopup">平台开票</view>
							</view>
						</view>
					</view>
				</view>
				<view class="oil-item-bottom">
					<view class="price-box-main">
						<view class="price">
							<view>活动价￥{{detail.insure_price || '0.00'}}</view>
						</view>
						<view class="price">
							<view>会员价￥{{detail.member_price || '0.00'}}</view>
						</view>
						<view class="" v-if="detail.platform_price == detail.price">
						</view>
						<view class="price" v-else>
							<view>平台价￥{{detail.platform_price || '0.00'}}</view>
						</view>
						<view class="o-price">
							<view>油站价￥{{detail.price || '0.00'}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 开票说明 -->
		<uni-popup ref="kpPopup" type="bottom" background-color="#fff">
			<view class="m-detail">
				<view class="w-center">
					<view class="m-detail-title df df-justify-content-between df-align-items">
						<view></view>
						<text>开票说明</text>
						<i class="iconfont icon-guanbi" style="color: #999999;font-size: 32rpx;" @click="close">
						</i>
					</view>
					<view class="" style="padding: 40rpx 0;font-size: 28rpx;">
						<scroll-view scroll-y="true" style="height: 550rpx;">
							<rich-text :nodes="kpText"></rich-text>
						</scroll-view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import mApi from '@/api/mine.js';
	import api from '@/api/order.js';
	import hapi from '@/api/home.js';
	export default {
		name: 'orderTop',
		data() {
			return {
				detail: '',
				kpText: '', //开票说明
				params: '',
			}
		},
		props: {
			info: {
				
			}
		},
		onLoad() {
			console.log(this.info,"组件的值");
			this.getDetail()
		},
		methods: {
			// 详情
			getDetail() {
				let _this = this;
				let address = uni.getStorageSync('address')
				uni.showLoading({
					title: '加载中…'
				});
				hapi.getStationDetail({
					id: _this.params.id,
					oil_type_id: _this.oil_type_id,
					lng: address.longitude,
					lat: address.latitude
				}).then(res => {
					if (res.code == 1) {
						_this.detail = res.data;
						// #ifdef MP-WEIXIN
						_this.kpText = res.data.agree[0].content;
						// #endif

						// #ifdef MP-ALIPAY
						let kpText = res.data.agree[1].content;
						/* 处理支付宝小程序富文本显示问题 */
						_this.kpText = parseHtml(kpText);
						// #endif

						_this.o_index = res.data.oil_id;
					}
					this.getStationOil();
					this.getOilGun();
					// this.getComman();
					// 获取会员加油金列表
					this.getMemberOilList();
					let userinfo = uni.getStorageSync('userinfo');
					if (userinfo) {
						this.getjiayoujinApi();
					};
					setTimeout(() => {
						this.getprice();
					}, 300);
					uni.hideLoading();
				}).catch(() => {
					uni.hideLoading()
				})
			},
			kpPopup() {
				this.$refs.kpPopup.open();
			},
			close() {
				this.$refs.kpPopup.close();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.order-top {
		.top-content {
			margin: 20rpx 30rpx;
			min-height: 330rpx;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 20rpx;

			.oil-item-top {
				display: flex;
				margin-bottom: 40rpx;

				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 50%;
				}

				.oil-item-data {
					width: calc(100% - 200rpx);
					margin-left: 20rpx;

					.oil-title {
						display: flex;

						text {
							width: calc(100% - 40rpx);
							margin-bottom: 15rpx;
							margin-top: 10rpx;
							font-size: 32rpx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #222222;
						}

						.collect {
							margin-left: 20rpx;
							margin-top: 10rpx;

							text {
								color: #F12F63;
								font-size: 50rpx;
							}
						}
					}

					.address-box {
						width: calc(100% - 80rpx);
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #444444;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;

						.address {
							line-height: 50rpx;
						}

						.distance-box {
							display: flex;
							align-items: center;
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: 400;
							color: #8F96AC;

							.GPS-img {
								margin-left: 20rpx;
								width: 38rpx;
								height: 38rpx;
							}

							.kp {
								color: #F12F63;
								margin-left: 30rpx;
								border: 1rpx solid #F12F63;
								padding: 4rpx 8rpx;
								border-radius: 8rpx;
							}
						}
					}
				}
			}

			.oil-item-bottom {
				border-top: 1rpx solid rgba(84, 84, 84, 0.15);
				padding-top: 30rpx;

				.price-box-main {
					display: flex;
					font-size: 23rpx;
					font-family: PingFang SC;
					font-weight: 450;

					.price {
						width: 24%;
						height: 35rpx;
						line-height: 35rpx;
						text-align: center;
						color: #F12F63;
						border: 1rpx solid rgba(241, 47, 99, 0.15);
						border-radius: 5rpx;
						margin-right: 8rpx;
						background-color: rgba(241, 47, 99, 0.1);
					}

					.o-price {
						width: 24%;
						height: 35rpx;
						line-height: 35rpx;
						text-align: center;
						border: 1rpx solid rgba(84, 84, 84, 0.15);
						border-radius: 5rpx;
						background-color: rgba(84, 84, 84, 0.1);
					}
				}
			}
		}
	}
</style>
